<?php


namespace app\community\oauth2\Repository;

use app\community\oauth2\Entities\ClientEntity;
use League\OAuth2\Server\Entities\ClientEntityInterface;
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;

class ClientRepository implements ClientRepositoryInterface
{

    public function getClientEntity($clientIdentifier): ClientEntityInterface
    {
        // TODO: Implement getClientEntity() method.
        return app(ClientEntity::class, [
            $clientIdentifier
        ]) -> getClient();
    }

    /**
     * 验证客户端账户信息
     * @param string $clientIdentifier
     * @param string|null $clientSecret
     * @param string|null $grantType
     * @return bool
     */
    public function validateClient($clientIdentifier, $clientSecret, $grantType): bool
    {
        // TODO: Implement validateClient() method.
        return app(ClientEntity::class, [
            $clientIdentifier
        ])  -> getClient()
            -> validateClient($clientSecret);
    }
}